home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / TranscriptWindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  4.9 KB  |  182 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:        TranscriptWindow.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __TYPES__
  15. #include <Types.h>
  16. #endif
  17.  
  18. #ifndef __WINDOWS__
  19. #include <Windows.h>
  20. #endif
  21.  
  22. #ifndef __MEMORY__
  23. #include <Memory.h>
  24. #endif
  25.  
  26. #ifndef __LIMITS__
  27. #include <Limits.h>
  28. #endif
  29.  
  30. #ifdef    __UNIVERSAL__
  31. #ifndef    __LOWMEM__
  32. #include <LowMem.h>
  33. #endif
  34. #else
  35. #ifndef    __SYSEQU__
  36. #include <SysEqu.h>
  37. #endif
  38. #endif
  39.  
  40. #ifndef __EVENTS__
  41. #include <Events.h>
  42. #endif
  43.  
  44. #ifndef __OSEVENTS__
  45. #include <OSEvents.h>
  46. #endif
  47.  
  48. #ifndef __STDIO__
  49. #include <stdio.h>
  50. #endif
  51.  
  52. /***********************************|****************************************/
  53.  
  54. const short kHMargin = 5;
  55. const short kVMargin = 10;
  56. const short kForceDepth = 16;
  57.  
  58. enum { forceUnchanged, forceOn, forceOff };
  59.  
  60.     typedef struct ForceState {
  61.         Boolean        toWindow;
  62.         Boolean        toFile;
  63.     } ForceState;
  64.  
  65. /***********************************|****************************************/
  66.  
  67. class TTranscriptWindow : public TDirectObject
  68. {
  69. public:                                TTranscriptWindow ( short windowID );
  70.                                     ~TTranscriptWindow ( );
  71.                                     
  72.     //    Call this to initialize the  globals
  73.       void Init(short numLines, short numCharsPerLine);
  74.     
  75.     //    Pass this routine an event, and it will check whether that event 
  76.     //    'belongs' to this debug window.  If it does, then it will handle the
  77.     //    event and return true; otherwise it will return false.
  78.       Boolean Event(EventRecord *anEvent);
  79.     
  80.     //    If you call this, then subsequent writelns will be sent to the indicated file.  (Assuming
  81.     //    writing to the file is enabled. Pass '' for the fileName to close any open file.
  82.             OSErr                     Redirect (short vRefnum, long dirID, Str255 fileName, Boolean append = false );
  83.             OSErr                     Redirect (const FSSpec& redirectFile, Boolean append );
  84.     
  85.       void Show (void);
  86.     
  87.     // Since it is now possible that one part of the program disables writelns to the window, you
  88.     //        might want to guarantee that certain writelns appear in the window.  ForceOutput saves
  89.     //        the values of gWrToWindow & gWrToFile on a stack (depth = kForceDepth), and sets
  90.     //        these values according to the parameters.  EndForce simply pops the stack.
  91.       void ForceOutput(short wrToWindow, short wrToFile);
  92.       void EndForce();
  93.     
  94.     
  95.     
  96.       void Append (Ptr textBuf, long byteCount);
  97.     
  98.     /* Call before SizeWindow if you need to resize the debug window programmatically*/
  99.       void InvalGrowBox();
  100.     
  101.     /* Call after SizeWindow if you need to resize the debug window programmatically*/
  102.       void Grown();
  103.     
  104.     //    Call the following procedures in response to events for the WriteLnWindow.
  105.     //    (Test the window receiving the event against gDebugWindowPtr.
  106.     
  107.       void ActivateEvent(short modifiers);
  108.       void MouseDown(short where, Point pt, short modifiers);
  109.       void UpdateEvent();
  110.       void Scroll(short howManyLines); /* for UTrace use; negative arg scrolls backwards*/
  111.     
  112.       void FlushOutputFile(void);
  113.  
  114.         void WindowFocus(void);
  115.         void    ContentFocus(void);
  116.         long    BaseLine(short ln) ;
  117.  
  118.         void DoScrolling(void);
  119.  
  120.         void Draw (void) const;
  121.         void Draw ( const Rect& rectToRedraw ) const;
  122.  
  123.         void NewLine(void);
  124.         void ShowPoint(Point pt);
  125.  
  126.         void AddEncodedText (Ptr dataPtr, long size);
  127.         void AddHexData (Ptr dataPtr, short dataSize );
  128.  
  129.     static Boolean IsLogWindowEvent ( const EventRecord& event );
  130.     friend pascal void TrackControlCallback ( ControlHandle aControl, short partCode );    
  131.     WindowPtr                                GetWindowPtr () const;
  132.  
  133.         
  134. protected:
  135.  
  136.         Boolean                                Initialize ( );
  137.         Boolean                                InitializeFontInfo ();
  138.         
  139.     short                                    fWindowResID ;
  140.     
  141.     WindowPtr    fDebugWindowPtr;    
  142.     long        fLines;
  143.     short        fPerLine;                    //    number of characters per line
  144.     long        fTotal;                        //    number of characters in all lines together
  145.     char**        fText;                        //    the ring buffer: blanks pad each line to 80 chars
  146.     short**        fLineLens;                    /*    # of real characters in each line; (*gLinesLens)^[0]
  147.                                                 is # of characters in the line that begins with
  148.                                                         (*fText)^[0] */
  149.  
  150.     long        fFirst;                        //    where in the ring buffer the top line starts
  151.     long        fLast;                        //    where in the ring buffer the bottom line starts
  152.     short        fPos;                        //    number of characters so far in the bottom line
  153.         
  154.     TextStyle                                fFaceInfo;
  155.     FontInfo                                fFontInfo;
  156.     short                                    fHeigth;
  157.     
  158.     ControlHandle    fSBars[2];                //    the window scroll bars
  159.     Point        fScrollOffset;                //    the position to which we are scrolled
  160.     Point        fViewSize;                    //    total view size
  161.     Point        fEndOfText;                    //    the pen position after drawing all the lines
  162.  
  163.     Rect        fStdDrag;
  164.     Rect        fStdSize;
  165.     RgnHandle        fARgn;
  166.  
  167.     Boolean        fGotRefNum;
  168.     short        fRefNum;                    //    refNum for redirect output
  169.     short        fVRefNum;                    //    likewise, vrefNum
  170.  
  171.     ForceState    fForceStack[kForceDepth];
  172.     short        fForcePtr;
  173.     
  174.     Boolean        fScrollWindowWhenTextIsAdded;
  175.     Boolean        fWrToWindow;
  176.     Boolean        fWrToFile;
  177.  
  178.     Boolean        fDirty;            //    whether unflushed data has been written.
  179. };
  180.  
  181. /***********************************|****************************************/
  182.